<!-- 用户设置 -->
<template>
    <div class="userbox">
        <!-- 用户框 -->
        <div class="item" v-for="(v, i) in user_arr" :key="i">
            <div><span>用户名：</span>{{ v.userName }}</div>
            <div><span>密码：</span>
                <b v-if="v.password">{{ v.password }}</b>
                <b v-else>٭٭٭٭٭٭</b>
            </div>
            <div v-if="!v.admin" v-show="v.userName !== roles"><span>操作：</span><span class="delitem"
                    @click="delClick(v.userId)">删除</span>
            </div>
        </div>
        <!-- 添加框 -->
        <div class="item additem" @click="isbool = !isbool">

            <div class="user">添加新账号</div>
            <div>
                <img class="img" src="../../../assets/imgx/add_num.png" alt="">
            </div>

        </div>
        <!-- 遮罩层 -->
        <div class="MaskLayeR" v-show="isbool">
            <slotCom>
                <template v-slot:com>
                    <div class="MaskLayeR_top">
                        <div class="user">添加新账号</div>

                        <img src="../../../assets/imgx/message-bg.png" alt="">

                        <span class="off" @click="isbool = false">×</span>


                    </div>
                    <div class="MaskLayeR_button">
                        <MaskLayeRFrom @UserListFun="UserListFun" :offClickFun="offClickFun" />
                    </div>
                </template>
            </slotCom>

        </div>
        <div class="zezaoc">

            <Btn_box />

        </div>

        <div class="lod" v-show="elIconWarningBool">
            <lodFile :doScTitle="doScTitle" />
        </div>
    </div>
</template>
<script>
import { userSettingsApi, delUserList, roleListFunApi } from "@/api/SettingsApi/index.js"
export default {
    components: {
        MaskLayeRFrom: () => import("./MaskLayeR_From/index.vue"),
        slotCom: () => import("@/components/SslotCom/top_index.vue"),
        Btn_box: () => import("@/components/uponelevel/index.vue"),
        lodFile: () => import("@/components/outfilelod/index.vue"),
    },
    data() {
        return {

            elIconWarningBool: false,
            doScTitle: "",
            isbool: false,
            user_arr: [],
            offClickFun: [],
            roles: "",
            item3: ""
        }
    },
    mounted() {
        this.funSerin()
        this.userlist()
        this.roLeListFun()
    },
    methods: {
        funSerin() {
            this.roles = this.$store.state.Userindex.user.userName
            console.log(this.roles);
        },
        roLeListFun() {
            roleListFunApi().then(res => {
                console.log(res);
                if (res.code == 200) {

                    this.offClickFun = res.rows;
                } else {
                    this.errorFun(res)

                }
            })
        },
        errorFun(item) {
            this.doScTitle = item.msg;
            this.elIconWarningBool = true
            clearInterval(this.time3)

            this.time3 = setInterval(() => {
                this.elIconWarningBool = false
            }, 3000)

        },
        UserListFun() {
            this.userlist()
            this.isbool = false;

        },
        // 
        delClick(id) {
            delUserList({
                params: {
                    userId: id,
                }
            }).then(res => {
                if (res.code == 200) {
                    this.userlist()
                } else {
                    this.errorFun(res)

                }


            })
        },
        userlist() {
            userSettingsApi().then(res => {
                // console.log(res);
                if (res.code == 200) {
                    this.user_arr = res.rows
                } else {
                    this.errorFun(res)
                }
            })
        }

    }
}
</script>
<style lang="less" scoped>
.lod {
    position: fixed;
    top: 5%;
    left: 42%;
    z-index: 999;

}

.zezaoc {
    width: 106px;
    height: 30px;
    position: fixed;
    font-size: 10px;
    top: 80px;
    left: 1770px;

    display: flex;
    cursor: pointer;

    div {
        width: 98.38px;
        height: 40.38px;
        background: #031231;
        opacity: 1;
        text-align: center;
        line-height: 40.38px;
        color: white;
        margin: 0px 5px;


    }


}

.userbox {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    position: relative;
    align-content: flex-start;

    .item {
        width: 242px;
        height: 120px;
        background: #04173D;
        opacity: 1;
        border: 0.5px solid #00479d;
        margin: 20px 25px;
        font-size: 16px;

        div {
            padding: 8px 47px;
            color: white;


            .img {
                width: 33px;
                height: 33px;
                background: none;
            }

            .delitem {
                color: #FF5757FF;
                cursor: pointer;
            }
        }
    }


    .additem {
        display: flex;
        flex-direction: column;
        align-items: center;
        cursor: pointer;
        justify-content: center;

    }

    .MaskLayeR {
        width: 453px;
        height: 262px;
        opacity: 0.95;
        position: absolute;
        top: 6%;
        right: 38%;

        border: 1px solid #113D71;
        background: #091123;

        box-shadow: inset 0px 0px 59px 0px #0D3EB8;
        opacity: 1;


        .MaskLayeR_top {
            width: 100%;
            height: 30px;
            line-height: 30px;
            margin-left: 5px;
            display: flex;
            position: relative;

            .user {
                width: 20%;
                height: 100%;
                text-align: center;
                color: white;

            }

            img {
                width: 80%;
                height: 100%;
                position: absolute;
                right: 0;
            }

            .off {
                width: 30px;
                height: 100%;
                font-size: 30px;
                line-height: 40px;
                position: absolute;
                right: 5px;
                color: #3580C7;
                top: -8px;
                cursor: pointer;

            }
        }

        .MaskLayeR_button {
            width: 300px;
            margin: 13px 0px 0px 63px;


        }

    }
}
</style>